﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace WorldOfMUDraClient
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class PConsole : Window
    {
        public PConsole()
        {
            InitializeComponent();
        }

        private void InitializeComponent()
        {
            throw new NotImplementedException();
        }

        private void rTitle_MouseDown(object sender, MouseButtonEventArgs e)
        {
            this.DragMove();
        }

        private void ClearInput()
        {
            tbInput.Text = "";
        }

        public void WriteLine(string text)
        {
            tbConsole.Text += '>' + text + '\n';
            tbConsole.ScrollToEnd();
        }

        public void WriteLine(string user, string text)
        {
            tbChat.Text += (user + ": " + text + '\n');
            tbChat.ScrollToEnd();
        }

        private void textBox1_KeyDown(object sender, KeyEventArgs e)
        {
            string input = tbInput.Text;
            List<string> tokens = input.Split(' ').ToList<string>();
            if (e.Key == Key.Enter)
            {
                if (tokens[0] == "say")
                {
                    this.WriteLine("You", input.Substring(3));
                    this.ClearInput();
                }
                else
                {
                    this.WriteLine(input);
                    this.ClearInput();
                }
            }
        }

        private void eClose_MouseDown(object sender, MouseButtonEventArgs e)
        {
            this.Close();
        }
    }

}
